<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>人员列表</title>
    <link href="layui/css/layui.css" rel="stylesheet">
    <style>
        table {
            width: 800px;
            border-collapse: collapse;
            position: absolute;
            margin-left: 100px;
            margin-top: 50px;
        }

        th {
            background-color: #f2f2f2;
        }
        tr:nth-child(even) {
            background-color: #90EE90;
        }
        tr:nth-child(odd) {
            background-color: #66FFFF;
        }
    </style>
</head>
<script type="application/javascript" src="js/jquery-3.7.1.js"></script>
<script type="application/javascript">
    $(function(){
        $(".del").click(function (){
            var id = $(this).data("id");
            $.ajax({
                url:"/person",
                data:{
                    action:"delPerson",
                    id:id,
                },
                type:"GET",
                dataType:"json",
                success:function (data){
                    // alert(data.msg);
                    location.href = "/person?action=queryPerson";
                }
            })
        })
    })
</script>
<body>

<table border="1">
    <thead>
    <h2>人员列表</h2>
    <tr>
        <th>编号</th>
        <th>姓名</th>
        <th>性别</th>
        <th>年龄</th>
        <th>等级</th>
        <th>部门</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach var="person" items="${personList}" varStatus="s">
        <tr>
            <td>${person.id}</td>
            <td>${person.name}</td>
            <td>${person.sex}</td>
            <td>${person.age}</td>
            <td>${person.rank}</td>
            <td>${person.department}</td>
            <td><a class="del" data-id="${person.id}" href="javascript:void(0)">删除</a></td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<button><a href="addPerson.jsp">添加</a></button>
</body>
</html>




